using System;
using System.Collections.Generic;
using System.Text;

using NHibernate;
using Zwms.Data.BusinessObjects;
using Zwms.Data.Base;
using Zwms.Data.CommonObject;
using NHibernate.Criterion;
using System.Reflection;

namespace Zwms.Data.ManagerObjects
{
    public partial interface IBilCountBillDetailManager : IManagerBase<Zwms.Data.BusinessObjects.BilCountBillDetail, string>
    {
        // Get Methods
        BilCountBillDetail GetById(System.String countBillCode, System.String stockCode);
    }

    partial class BilCountBillDetailManager : ManagerBase<Zwms.Data.BusinessObjects.BilCountBillDetail, string>, IBilCountBillDetailManager
    {
        #region Constructors

        public BilCountBillDetailManager()
            : base()
        {
        }
        public BilCountBillDetailManager(INHibernateSession session)
            : base(session)
        {
        }

        #endregion

        #region Get Methods

        public override BilCountBillDetail GetById(string id)
        {
            string[] keys = id.Split('^');

            if (keys.Length != 4)
                throw new Exception("Invalid Id for BilCountBillDetailManager.GetById");

            return GetById(keys[0], keys[1]);
        }
        public BilCountBillDetail GetById(System.String countBillCode, System.String stockCode)
        {
            ICriteria criteria = Session.GetISession().CreateCriteria(typeof(BilCountBillDetail));

            criteria.Add(NHibernate.Criterion.Expression.Eq("CountBillCode", countBillCode));
            criteria.Add(NHibernate.Criterion.Expression.Eq("StockCode", stockCode));

            BilCountBillDetail result = (BilCountBillDetail)criteria.UniqueResult();

            if (result == null)
                throw new NHibernate.ObjectDeletedException("", null, null);

            return result;
        }

        #endregion
    }
}